package main

import "fmt"

// 声明一个自定义类型
type myint int

// 定义一个结构体
type Book struct {
	title string
	auth  string
}

// 值传递，传递一个book的副本，修改值不会改变原始内容
func changeBook(book Book) {
	book.auth = "666"
}

// 址传递
func changeBook2(book *Book) {
	book.auth = "666"
}

func main() {
	var a myint = 10
	fmt.Println("a = ", a)
	fmt.Printf("type of a = %T\n", a)

	var book1 Book
	book1.title = "Golang"
	book1.auth = "zhangsan"
	// %v可以打印任一格式的类型
	fmt.Printf("自定义结构体，book1 = %v\n", book1)

	changeBook(book1)
	fmt.Printf("调用传值函数后，值未发生修改，book1 = %v\n", book1)

	changeBook2(&book1)
	fmt.Printf("调用传址函数后，值发 生修改，book1 = %v\n", book1)
}
